﻿using System;
using System.Collections.Generic;

namespace Utilities
{
    public class Form
    {
        private List<FormItem> items;

        public List<FormItem> Items { get { return items; } }

        public Dictionary<string, object> Result; 

        public string BtnSubmit { get; set; }
        public string BtnExit { get; set; }
        public string Title { get; set; }

        public Form()
        {
            items = new List<FormItem>();
            Result = new Dictionary<string, object>();
            Title = "Formular";
            BtnSubmit = "Send";
            BtnExit = "Annuller";
        }

        public void CreateTextBox(string name, string labelContent, string textBoxText = "", bool selected = false)
        {
            items.Add(new FormItem(name, labelContent, new TextBox(textBoxText, selected)));
            Result.Add(name, textBoxText);
        }

        public void CreateIntegerBox(string name, string labelContent, string textBoxText = "", bool selected = false)
        {
            items.Add(new FormItem(name, labelContent, new IntegerBox(textBoxText, selected)));
            Result.Add(name, textBoxText);
        }

        public void CreateComboBox<T>(string name, string labelContent, IEnumerable<T> comboBoxItems, string displayMemberPath, object selectedItem = null)
        {
            items.Add(new FormItem(name, labelContent, new ComboBox (comboBoxItems, displayMemberPath, selectedItem)));
            Result.Add(name, null);
        }

        public void CreateDateBox(string name, string labelContent, DateTime startDate)
        {
            items.Add(new FormItem(name, labelContent, new DateBox(startDate)));
            Result.Add(name, startDate);
        }

        public void CreateDisabledTextBox(string name, string labelContent, string textBoxText)
        {
            items.Add(new FormItem(name, labelContent, new DisabledTextBox(textBoxText)));
            Result.Add(name, textBoxText);
        }

        #region Nested classes



        #endregion

    }



}
